package someTestExcemple.huaweiOd.doublepointer;
import java.util.*;
//华为OD机试 - 考勤信息 - 双指针（Java 2025 A卷 100分）
//https://blog.csdn.net/guorui_java/article/details/132393257
public class AttendanceInformation {
    public static final String ABSENT="absent"; //缺勤
    public static final String LATE="late"; //迟到
    public static final String LEAVE_EARLY="leaveearly"; //早退
    public static final String PRESENT="present"; //正常
    public static final String[] ATTENDANCE_TYPE={ABSENT,LATE,LEAVE_EARLY,PRESENT};
    public static void main(String[] args) {
        Scanner sc =new Scanner(System.in);
        int n = Integer.parseInt(sc.nextLine());
        List<Boolean> result = new ArrayList<>();
       for(int i = 0; i < n; i++) {
           String Line = sc.nextLine();
           String[] split = Line.split(" ");
           //System.out.println(isAttendance(split));
           result.add(isAttendance(split));
       }
        sc.close();
       StringJoiner joiner = new StringJoiner(" ");
       for(Boolean b : result) {
           joiner.add(b.toString());
       }
        System.out.println(joiner);


    }
    public static boolean isAttendance(String[] attendance) {
        //缺勤数量
        int absentCount=0;
        for(int i = 0; i < attendance.length; i++) {
            String s = attendance[i];
            if(!Arrays.asList(ATTENDANCE_TYPE).contains(s)) {
                return false;
            }
            //缺勤
            if(s.equals(ABSENT)) {
                absentCount ++;
                //缺勤数量大于1 -不得全勤奖
                if(absentCount>1) {
                    return false;
                }
            }
            //连续迟到早退
            if(s.equals(LATE) || s.equals(LEAVE_EARLY)) {
                if(i+1<=attendance.length-1) {
                    String next = attendance[i+1];
                    if(next.equals(LATE) || next.equals(LEAVE_EARLY)) {
                        return false;
                    }

                }
            }
        }
        //检查任意连续7次考勤中是否有超过3次异常 --窗口函数-窗口长7
        //注意这里如果天数不够7天，超过3次异常 ，还是算全勤
        int len = 7;
        int count = 0;
        for(int i=0; i<attendance.length; i++) {
            for(int j=i;j<attendance.length; j++) {
                if(attendance[j].equals(ABSENT) || attendance[j].equals(LATE) || attendance[j].equals(LEAVE_EARLY)) {
                    count++;
                    //j-i == 7别忘记
                    if(count > 3 && j-i==len) {
                        return false;
                    }

                }
            }
        }
        return true;
    }
    //2
    //present
    //present absent present present leaveearly present absent
}
